/*
 * @Author: 45F
 * @Date: 2019-07-31 22:14:25
 * @LastEditors: 45F
 * @LastEditTime: 2019-10-25 15:55:57
 * @Description: 案事件状态管理
 */

export default {
  namespaced: true,
  state: {
    status: Number,
    incidentName: sessionStorage.incidentName,
    sourceObject: [
      {
        id: 1,
        name: '导入'
      },
      {
        id: 2,
        name: '基础库'
      },
      {
        id: 3,
        name: '案事件'
      },
      {
        id: 4,
        name: '情报'
      },
      {
        id: 5,
        name: '录入'
      },
      {
        id: 6,
        name: '监测'
      }
    ],
    taskStatus: Number,
    isAddModelSelect: false,
    addModelSelectList: []
  },
  mutations: {
    setStatus (state, status) {
      state.status = status
    },
    setIncidentName (state, name) {
      state.incidentName = name
      sessionStorage.incidentName = name
    },
    setTaskStatus (state, status) {
      state.taskStatus = status
    },
    setIsAddModelSelect (state, value) {
      state.isAddModelSelect = value
    },
    setAddModelSelectList (state, { data, checked }) {
      debugger
      let newData = [...state.addModelSelectList]
      if (checked) {
        state.addModelSelectList.push(data)
      } else {
        state.addModelSelectList = newData.filter(
          item => item.phoneNumber !== data.phoneNumber
        )
      }
    },
    resetAddModelSelectList (state) {
      state.addModelSelectList = []
    }
  }
}
